package test.thread;

import java.util.concurrent.TimeUnit;

import static java.lang.Thread.sleep;

/**
 * Created by crj on 2017/8/10.
 */
public class Demo1 {
     volatile  boolean   flag =true;
     long  i=(10000000*9999);

    public void  test(){
        System.out.println("start");
        while(flag){
            i++;
            System.out.println(i);
        }
        System.out.println("end");
    }

    public static void main(String[] args) {
        Demo1 t =new Demo1();
        new Thread(t::test,"t").start(); //jdk 8写法
        //这里睡1秒是为了模拟现象
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
       // t.flag =false;
    }
}
